package book.nettyinaction.ch12;

import io.netty.buffer.ByteBufUtil;
import io.netty.util.internal.StringUtil;

public class NotAnSSLTLSRecord {

    /**
     *
     * 输出如下, 参考 <https://www.jianshu.com/p/d2b89635e374>
     *
GET / HTTP/1.1
Host: localhost:8080
Connection: keep-alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*\\/*;q=0.8
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,ja;q=0.7,la;q=0.6
     *
     *
     * @param args
     */
    public static void main(String[] args) {
        String code = "474554202f20485454502f312e310d0a486f73743a206c6f63616c686f73743a383038300d0a436f6e6e656374696f6e3a206b6565702d616c6976650d0a43616368652d436f6e74726f6c3a206d61782d6167653d300d0a557067726164652d496e7365637572652d52657175657374733a20310d0a557365722d4167656e743a204d6f7a696c6c612f352e30202857696e646f7773204e5420362e313b20574f57363429204170706c655765624b69742f3533372e333620284b48544d4c2c206c696b65204765636b6f29204368726f6d652f36382e302e333434302e313036205361666172692f3533372e33360d0a4163636570743a20746578742f68746d6c2c6170706c69636174696f6e2f7868746d6c2b786d6c2c6170706c69636174696f6e2f786d6c3b713d302e392c696d6167652f776562702c696d6167652f61706e672c2a2f2a3b713d302e380d0a4163636570742d456e636f64696e673a20677a69702c206465666c6174652c2062720d0a4163636570742d4c616e67756167653a207a682d434e2c7a683b713d302e392c656e3b713d302e382c6a613b713d302e372c6c613b713d302e360d0a0d0a";
        // byte[] bytes = ByteBufUtil.decodeHexDump(code); // `4.1.6.Final`中没有这个API
        byte[] bytes = StringUtil.decodeHexDump(code, 0, code.length());
        System.out.println(new String(bytes));
    }
}
